<!DOCTYPE html>
<html>
<head>
    <script src="/js-test-resources/js-test.js"></script>
    <script>
        description('Check that a CSP header added by a 304 response does not override one from the original request.');
        window.jsTestIsAsync = true;

        var frame1, frame2;
        function frameLoaded() {
            frame1 = document.querySelector('iframe');

            frame2 = document.createElement('iframe');
            document.body.appendChild(frame2);
            frame2.onload = checkState;

            frame2.src = frame1.src;
        }

        function checkState() {
            debug('Check that the nonce is the same, meaning that the document was only generated once:');

            shouldBeTrue('frame1.contentDocument.querySelector("input").value == frame2.contentDocument.querySelector("input").value');
            finishJSTest();
        }
    </script>
</head>
<body>
    <iframe src="http://127.0.0.1:8000/security/contentSecurityPolicy/resources/nph-cached-csp.pl" onload="frameLoaded()"></iframe>
</body>
</html>
